/*
package com.itheima.security;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.domian.UserLogin;
import com.itheima.service.UserLoginService;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

*/
/**
 * @author althle
 * @create 08-25-15:12
 * @功能
 * @注释
 *//*


public class UserService implements UserDetailsService {


    @Reference
    private UserLoginService userLoginService;

    public static Map<String ,UserLogin> map = new HashMap<>();
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        UserLogin byName = userLoginService.findByName(username);
        String username1 = byName.getUsername();
        String password = byName.getPassword();

        UserLogin userLogin = new UserLogin();
        userLogin.setUsername(username1);
        userLogin.setPassword(password);
        map.put(userLogin.getUsername(),userLogin);

        UserLogin userLogin1 = map.get(username);
        if(userLogin1 == null){
         //根据用户名没有查询到用户
         return null;
        }
        //模拟数据库中的密码，后期需要查询数据库
        String passwordInDb = "{noop}" + userLogin1.getPassword();
        List<GrantedAuthority> list = new ArrayList<>();
        //授权，后期需要改为查询数据库动态获得用户拥有的权限和角色
        list.add(new SimpleGrantedAuthority("add"));
        list.add(new SimpleGrantedAuthority("delete"));
        list.add(new SimpleGrantedAuthority("ROLE_ADMIN"));

        UserDetails user = new User(username,passwordInDb,list);
        return user;
    }
}
*/
